import { defineStore } from "pinia";
import {httpInstance} from "@api/http"
export const useUserInfoStore=defineStore("userInfo",()=>{

    const setAuth=(token:string)=>{
        
       localStorage.setItem("token",token)
    }
    const authFromLocal=()=>{
       const token=localStorage.getItem("token")
       if(token){
           setAuth(token)
           return true
       }
           return false
       
    }
    const removeAuth=()=>{
     delete httpInstance.defaults.headers.Authorization
     localStorage.removeItem("token")
    }
    return {
        setAuth,
        authFromLocal,
        removeAuth
    }
})